<template>
  <div 
    class="glass-card" 
    :class="[
      `glass-card--${variant}`,
      { 'glass-card--hoverable': hoverable },
      { 'glass-card--loading': loading }
    ]"
  >
    <div v-if="loading" class="glass-card__loading">
      <div class="loading-spinner"></div>
    </div>
    
    <div v-if="$slots.header" class="glass-card__header">
      <slot name="header"></slot>
    </div>
    
    <div class="glass-card__body">
      <slot></slot>
    </div>
    
    <div v-if="$slots.footer" class="glass-card__footer">
      <slot name="footer"></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  variant?: 'default' | 'primary' | 'secondary' | 'transparent'
  hoverable?: boolean
  loading?: boolean
}

withDefaults(defineProps<Props>(), {
  variant: 'default',
  hoverable: false,
  loading: false
})
</script>

<style scoped>
.glass-card {
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  position: relative;
}

.glass-card--default {
  background: rgba(30, 42, 58, 0.8);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.glass-card--primary {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.2);
}

.glass-card--secondary {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(139, 92, 246, 0.3);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.2);
}

.glass-card--transparent {
  background: rgba(15, 23, 42, 0.6);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.glass-card--hoverable {
  cursor: pointer;
}

.glass-card--hoverable:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
}

.glass-card--primary.glass-card--hoverable:hover {
  box-shadow: 0 12px 40px rgba(59, 130, 246, 0.3);
}

.glass-card--secondary.glass-card--hoverable:hover {
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.3);
}

.glass-card__loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top: 3px solid #60a5fa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.glass-card__header {
  padding: 20px 24px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 20px;
  padding-bottom: 16px;
}

.glass-card__body {
  padding: 24px;
}

.glass-card__header + .glass-card__body {
  padding-top: 0;
}

.glass-card__footer {
  padding: 0 24px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 20px;
  padding-top: 16px;
}

.glass-card__body + .glass-card__footer {
  padding-bottom: 24px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .glass-card__header,
  .glass-card__body,
  .glass-card__footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}
</style>
